package com.sikao.app.ui;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sikao.app.R;
import com.sikao.app.ui.base.BaseActivity;


public class AboutUsActivity extends BaseActivity implements View.OnClickListener {

	private TextView titleTv;
	private TextView phoneNumberTv;
	private ImageView backIv;



	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_about_us);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void initData() {
	}

	@Override
	protected void initView() {
		titleTv = (TextView) findViewById(R.id.title_middle_tv);
		phoneNumberTv = (TextView) findViewById(R.id.phone_number_tv);
		backIv = (ImageView) findViewById(R.id.title_left_img);

	}

	@Override
	protected void initListener() {

		backIv.setOnClickListener(this);
		phoneNumberTv.setOnClickListener(this);

	}

	@Override
	protected void init() {
		titleTv.setText("联系我们");
		backIv.setVisibility(View.VISIBLE);

	}



	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.title_left_img:
				finish();
				break;
			case R.id.phone_number_tv:

				if (!TextUtils.isEmpty(phoneNumberTv.getText())){
					AlertDialog dialog;
					AlertDialog.Builder builder = new AlertDialog.Builder(this);
					builder.setTitle("确认拨打电话吗?");
					builder.setMessage(phoneNumberTv.getText());
					builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
							Intent intent = new Intent(Intent.ACTION_DIAL);
							Uri data = Uri.parse("tel:" + phoneNumberTv.getText());
							intent.setData(data);
							startActivity(intent);

						}
					});
					builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
						}
					});
					dialog = builder.create();
					dialog.show();
				}


				break;

			default:
				break;
		}
	}


}
